<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="feedstyle.css" type="text/css" />
<title>mjt google feeds</title>
<script type="text/javascript" src="http://mjtemplate.org/dist/mjt-0.6/mjt.js"></script>
<script type="text/javascript" src="./google-api-keys.js"></script>
<script type="text/javascript">
    load_google_api('http://www.google.com/jsapi?key=');
</script>
<script type="text/javascript">

    google.load("feeds", "1");

    function initialize() {
      var top = mjt.run('top');

      var feeduri = mjt.urlquery.feed;
      if (typeof feeduri == 'undefined')
          feeduri = "http://blog.freebase.com/?feed=atom";
      document.title = 'feed: ' + feeduri;

      var feed = new google.feeds.Feed(feeduri);
      feed.load(function(result) { mjt.run('feed', top.showfeed, [result]); });
    }
    google.setOnLoadCallback(initialize);
</script>
</head>
<body>
<div>
This is a toy feed reader using <a href="http://mjtemplate.org">Mjt</a> to
read Google's new <a href="http://code.google.com/apis/ajaxfeeds/documentation/">AJAX feed API</a>.
</div>
<div>
some feeds:
<a href="?feed=http://blog.freebase.com/%3Ffeed%3Datom">The Freebase Dev Blog</a>
| <a href="?feed=http://googleajaxsearchapi.blogspot.com/atom.xml">Google AJAX Search API Blog</a>
</div>
<!-- compare to <a href="http://code.google.com/apis/ajaxfeeds/documentation/helloworld.html">google example</a> -->
<div id="top" style="display:none;">
<div class="feedform">
<form action="feed.html">
<div>xml feed uri: 
    <input type="text" size="70" name="feed" value="${mjt.urlquery.feed||''}" />
<input type="submit" value="read" />
</div>
</form>
</div>
<div mjt.def="showfeed(result)">
<div mjt.choose="">
<div mjt.when="result.status != '200' &amp;&amp; result.error">
      error: <b>$result.error.message</b>
</div>
<div mjt.when="result.status.code == 200">
<pre mjt.script="">
        document.title = 'feed: ' + result.feed.title;
      </pre>
<h1 class="feedtitle"><a href="$result.feed.link">$result.feed.title</a></h1>
<div mjt.for="entry in result.feed.entries" class="entry">
<div class="entryheader">
<a href="$entry.link" class="entrytitle">$entry.title</a>
<span mjt.if="entry.categories instanceof Array &amp;&amp; entry.categories.length&gt;0">
            in: <span mjt.for="cat in (entry.categories||[])" class="category">$cat</span>
</span>
<div>
            &nbsp;&nbsp;&nbsp;&nbsp;
            <span class="author">${entry.author||''}</span> -
            <span class="date">${entry.publishedDate||''}</span>
</div>
</div>
<!-- XXX security - does google sanitize?  we sure don't... -->
<div class="content">${mjt.bless(entry.content)}</div>
</div>
</div>
<div mjt.otherwise="">
<b>unknown response type from google feed api</b>
</div>
</div>
</div>
</div>
<!-- the feed view gets pasted here when ready -->
<div id="feed"></div>
</body>
</html>
